#include <iostream>
#include <cassert>

using namespace std;

class A{
    void test(float a){cout<<"1";}
};
class B:public A{
    void test(int b){cout<<"2";}
};

/*
void test1(){
    A *a=new A;
    B *b=new B;
    a=b;
    a.test(1.1);
}
*/

int getMonthDay(int year, int month){
    assert(month > 0 && month < 13);
    int monthArray[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    if(month == 2 && (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)))
        return 29;
    return monthArray[month];
}

int getDays(int year, int month, int day){
    int days = 0;
    for (int i = 1; i < month; ++i) {
        days += getMonthDay(year, i);
    }
    days += day;
    return days;
}

void Test1(){
    int year;
    int month;
    int day;
    int days = 0;
    while(cin >> year >> month >> day){
        days = getDays(year, month, day);
        cout << days << endl;
    }
}

int main() {
    //test1();
    Test1();
    return 0;
}

